<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 编写一个函数求两个数字之间有多少个质数 例如：fn(100, 200) ，在控制台输出 100 - 200 之间的所有质数
        function fn(num) {
            for (var i = 2; i < num; i++) {
                if (num % i == 0) {
                    console.log(num + "不是质数");
                    return 0;
                }
            }
            console.log(num + "是质数");
            return 1;
        }
        function fns(num, num1) {
            var count = 0;
            if (num1 > num) {
                for (num; num <= num1; num++) {
                    count += fn(num);
                }
            } else {
                for (num1; num1 <= num; num1++) {
                    count += fn(num1);
                }
            }
            console.log(count);
        }
        var num = +prompt("请输入一个数:");
        var num1 = +prompt("请输入一个数:");
        fns(num, num1);
    </script>
</body>

</html>